<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="c" width="300" height="300" style="border: 1px solid #ccc;"></canvas>

    <script>
        const cnv = document.getElementById('c')
        const cxt = cnv.getContext('2d')

        //外层矩形
        cxt.moveTo(50,50)
        cxt.lineTo(260,50)
        cxt.lineTo(260,260)
        cxt.lineTo(50,260)
        cxt.closePath()

        //内层矩形
        cxt.moveTo(200,100)
        cxt.lineTo(100,100)
        cxt.lineTo(100,200)
        cxt.lineTo(200,200)
        cxt.closePath()
        cxt.fill()
        </script>
</body>
</html>